from Init_Cond import *

###***Print results to a file titled "Results(t_x)"***###
def f(x, M, Rigid_Roche, Roche, r_synch):
    t = x
    output = open('Results(t_' + str(t/year - (t/year)%1.0) + ').txt', 'w')
    print('M = ', M, 'RRl = ', Rigid_Roche, 'FRL = ', Roche, 'r_synch = ', r_synch, file = output)
    print('Time = ', t/year, ' Total Satellite Mass = ', sum(Sat_M), ' Disk Mass = ', sum(m), file = output)
    print('i,', 'r,', 'm,', 'sigma,', file = output)
    for i in range(int(N)):
        print(str(i) + ',', str(R_M[i]) + ',', str(m[i]) + ',', str(sigma[i]) + ',', file = output)
    print('a,', 'Sat_M', 'Sat_r', 'Sat_Rad', file = output)
    for a in range(len(Sat_M)):
        if Sat_M[a] > 0.0:
            print(a, Sat_M[a], Sat_r[a], Sat_Rad[a], file = output)
    output.close()

def g(t, last):
    output = open('Results(t_' + str(t/3600. - (t/3600.)%1.0) + ').txt', 'w')
    for a in range(len(Sat_M)):
        if Sat_M[a] > 0.0:
            print(a, str(Sat_r[a]/R_Mars) + ',', str((Sat_r[a] - rhill[a])/R_Mars) + ',', str(Sat_M[a]/M_Deimos), file = output)


def s(t):
    output = open('Results(t_' + str(t/year - (t/year)%1.0) + ').txt', 'w')
    print(t/year, 'Disk Mass = ', sum(m), '  Total Satellite Mass', sum(Sat_M), file = output)
    output.close()
